package com.ssy.lingxi.purchase.entity.tender;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.io.Serializable;
import java.util.List;

/**
 * 招标物料表
 * @author jw.chen
 * @version 2.0.0
 * @date 2021/3/1
 */
@Getter
@Setter
@Entity
@Table(schema = "public", name = "purchase_invite_tender_materiel")
public class InviteTenderMateriel implements Serializable {
    private static final long serialVersionUID = 1945006225586629047L;
    /**
     * 主键id
     */
    @Id
    @GeneratedValue(strategy= GenerationType.SEQUENCE, generator="invite_tender_materiel_seq")
    @SequenceGenerator(sequenceName="purchase_invite_tender_materiel_seq", name="invite_tender_materiel_seq",allocationSize = 1)
    private Long id;

    /**
     * 招标id
     */
    @JsonIgnore
    @ManyToOne(cascade = {CascadeType.PERSIST})
    @JoinColumn(name="inviteTenderId",referencedColumnName = "id")
    private InviteTender inviteTender;

    /**
     * 物料id(原货品表id)
     */
    @Column(columnDefinition = "int8")
    private Long goodsId;

    /**
     * 物料编号
     */
    @Column(columnDefinition = "varchar(20)", nullable = false)
    private String code;

    /**
     * 物料名称
     */
    @Column(columnDefinition = "varchar(40)", nullable = false)
    private String name;

    /**
     * 规格型号
     */
    @Column(columnDefinition = "varchar(40)", nullable = false)
    private String type;

    /**
     * 会员品类id
     */
    @Column(columnDefinition = "varchar(250)", nullable = false)
    private String categoryId;

    /**
     * 会员品类名称
     */
    @Column(columnDefinition = "varchar(20)", nullable = false)
    private String categoryName;

    /**
     * 品牌名称
     */
    @Column(columnDefinition = "varchar(20)")
    private String brandName;

    /**
     * 单位id
     */
    @Column(columnDefinition = "int8", nullable = false)
    private Long unitId;

    /**
     * 单位名称
     */
    @Column(columnDefinition = "varchar(20)", nullable = false)
    private String unitName;

    /**
     * 采购数量
     */
    @Column(columnDefinition = "decimal")
    private Double count;

    /**
     * 附件
     */
    @JsonManagedReference
    @OneToMany(mappedBy = "inviteTenderMateriel", cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE})
    private List<InviteTenderMaterielFile> file;

    /**
     * 会员id
     */
    @Column(columnDefinition = "int8", nullable = false)
    private Long memberId;

    /**
     * 会员名称
     */
    @Column(columnDefinition = "varchar(50)", nullable = false)
    private String memberName;

    /**
     * 会员角色id
     */
    @Column(columnDefinition = "int8", nullable = false)
    private Long memberRoleId;

    /**
     * 会员角色名称
     */
    @Column(columnDefinition = "varchar(50)", nullable = false)
    private String memberRoleName;

    /**
     * 用户id
     */
    @Column(columnDefinition = "int8", nullable = false)
    private Long userId;

    /**
     * 用户名称
     */
    @Column(columnDefinition = "varchar(50)", nullable = false)
    private String userName;
}
